import logging
import multiprocessing
from logging.config import dictConfig

import markdown2

from flask import Flask

from grayspread import lsenv
from grayspread.endpoints.main import main


logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)


def make_app():
    app = Flask(__name__)
    #app.config.update(app_conf)

    pid = multiprocessing.current_process().pid
    logger.info(f'Starting grayspread webapp with PID: {pid}.')

    app.register_blueprint(main)

    app.jinja_env.filters.update({
        'md': markdown2.markdown,
    })

    return app


if __name__ == '__main__':
    make_app()
